package com.suineg.pms.service.fee;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.collect.Lists;
import com.suineg.pms.entity.fee.FeeScal;
import com.suineg.pms.repository.fee.FeeScaleDao;
import com.suineg.pms.util.StringUtils;

/**
 * 交费基准
 *@author Suine
 */
@Service
@Transactional(readOnly = true)
public class FeeScaleService {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private FeeScaleDao dao;
	
	public FeeScal get(Long id){
		return dao.findOne(id);
	}
	
	public void save(FeeScal feeScal){
		dao.save(feeScal);
	}
	
	public void delete(Long id){
		dao.delete(id);
	}
	
	public FeeScal findByName(String name){
		return dao.findByName(name);
	}

	public List<FeeScal> findAll(){
		return Lists.newArrayList(dao.findAll());
	}
	
	public List<FeeScal> findByIds(String ids){
		if(StringUtils.isEmpty(ids)){
			return null;
		}
		List<Long> idList = Lists.newArrayList();
		for(String s : ids.split(",")){
			idList.add(Long.valueOf(s));
		}
		return Lists.newArrayList(dao.findAll(idList));
	}
}

